<template>
  <div class="ali-header">
    <div class="ali-d-flex left">
      <el-button size="medium" icon="el-icon-back" class="ali-font20" @click="handleBack" />
      <el-button size="medium" class="ali-font14 ali-ml0" :loading="reloadLoading" @click="handleReload">首页</el-button>
      <i class="el-icon-loading ali-ml5 ali-font24" v-if="globalLoading"></i>
    </div>
    <div class="ali-d-flex">
      <!--      <a class="ali-font14" href="https://www.aliyundrive.com/drive/file/backup" target="_blank">aliPan.com</a>-->
      <el-button size="medium" class="ali-font14 ali-ml5 ">列表</el-button>
      <!--      <el-button size="medium" class="ali-ml0">分享</el-button>-->
      <el-button :loading="loading" size="medium" class="ali-ml0" @click="reloadRefreshToken">刷新</el-button>
    </div>
  </div>
</template>
<script>
import { reloadRefreshToken } from '@/api/aliPan'
import { mapState } from 'vuex'

export default {
  name: 'AliHeader',
  data() {
    return {
      loading: false,
      reloadLoading: false
    }
  },
  computed: {
    ...mapState({
      globalLoading: state => state.globalLoading
    })
  },
  methods: {
    reloadRefreshToken() {
      // this.loading = true
      // reloadRefreshToken().then((res) => {
      //   // eslint-disable-next-line eqeqeq
      //   if (res.code == 0) {
      //     this.$message.success('Token 刷新成功')
      //   }
      //   this.loading = false
      // })
      window.location.reload()
    },
    handleReload() {
      // this.$emit('getAliPanData')
      window.location.reload()
    },
    handleBack() {
      this.$emit('handleBack')
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep{
  .el-button{
    border:none
  }
  .el-button--medium{
    padding:10px 5px;
  }
  .ali-d-flex.left{
    .el-button--medium{
      padding:10px 2px;
    }
  }
}
.ali-header{
  justify-content: space-between;
  box-shadow: 0 1px 5px #e1e1e1;
  padding: 0 0.5em 0 0.5em;
  display: flex;
  align-items: center;
  position: fixed;
  height: 3em;
  width: 100%;
  z-index: 1000;
}
.more{
  transform: rotate(90deg);
}
.custom-loading{
  width: 30px;
  height: 30px;
}
::v-deep{
  .el-loading-spinner .circular{
    width: 30px;
    height: 30px;
  }
}
</style>
